package com.only4play.practice.common.enums.pay;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.only4play.codegen.support.constants.BaseEnum;

import java.util.Optional;

/**
 * @author mengdy
 */
public enum TradeTypeEnum implements BaseEnum<TradeTypeEnum> {


    PAY(100,"支付"),
    REFUND(- 100,"退款"),
    TRANSFER(- 101,"转账"),
    ;

    TradeTypeEnum(Integer code, String name) {
        this.code = code;
        this.name = name;
    }
    @EnumValue
    private Integer code;
    //  @JsonValue
    private String name;

    @Override
    public Integer getCode() {
        return this.code;
    }

    @Override
    public String getName() {
        return this.name;
    }

    public static Optional<TradeTypeEnum> of(Integer code) {
        return Optional.ofNullable(BaseEnum.parseByCode(TradeTypeEnum.class, code));
    }

}
